home *** CD-ROM | disk | FTP | other *** search
- Path: anvil.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: newbie question concerning fread
- Date: 28 Feb 1996 13:33:34 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Distribution: inet
- Message-ID: <4h2hneINN9c2@anvil.ugrad.cs.ubc.ca>
- References: <rblayney.824643669@extro> <4gqejmINNh5@keats.ugrad.cs.ubc.ca> <825453118snz@genesis.demon.co.uk>
- NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
-
- In article <825453118snz@genesis.demon.co.uk>,
- Lawrence Kirby <fred@genesis.demon.co.uk> wrote:
- >In article <4gqejmINNh5@keats.ugrad.cs.ubc.ca>
- > c2a192@ugrad.cs.ubc.ca "Kazimir Kylheku" writes:
- >
- >>The two are equivalent, since in C, an "E1[E2]", where E1 and E2 are
- >>expressions, is the same as *((E1) + (E2)). One neat effect of this definition
- >>is that if you have an array called 'a', and an index called 'i', you can refer
- >>to the ith element as either a[i] or i[a].
- >
- >But certainly not [a]i or [i]a
- >
- >>Hence both of these constructs give the letter 'x':
- >
- >>
- >> char x = "abcx"[3];
- >> char x = [3]"abcx"; /* This is a syntax error */
- >> char x = ["abcx"]3; /* And so is this */
- >> char x = 3["abcx"];
-
- That's weird. ? I clearly said "both", and then I somehow gave four things of
- which two are wrong.
-
- The [] are part of the production of a postfix expression, which expects the
- [] pair to _follow_ another non-terminal. In no production of the grammar can
- [] be followed by anything other than an operator (possibly '[' itself!) or a
- terminating semicolon.
-
- I apologize for the error.
- --
-
-